
#include "GameString.h"


GameString* gGameString = F_NULL;


GameString::GameString()
{
	gGameString = this;

}


GameString::~GameString()
{

}


fvoid			GameString::Init()
{

}


fvoid			GameString::Release()
{
	delete mThis;
	mThis = F_NULL;
}


const fbyte*	GameString::Convert( const fwchar* buffer )
{
	static fbyte Converbuffer[ 4096 ] = {};

	//WideCharToMultiByte( CP_UTF8 , 0, buffer , -1 , Converbuffer , 1024 , F_NULL , F_NULL );

	return Converbuffer;
}


const fwchar*	GameString::GetString( const fbyte* id )
{
	if ( mStringMap.find(id) != mStringMap.end() )
		return mStringMap[id].c_str();

	return F_NULL;
}

const fbyte*	GameString::GetUtf8String( const fbyte* id )
{
	if ( mUtf8StringMap.find(id) != mUtf8StringMap.end() )
		return mUtf8StringMap[id].c_str();

	return F_NULL;

}

const fwchar*	GameString::GetTime( fint32 time )
{
	fint32 hour = time / 3600;
	fint32 min = (time - hour * 3600) / 60;
	fint32 sec = time - hour * 3600 - min * 60;

	static fwchar buffer[64] = {};

	swprintf( buffer , 64 , L"%d:%d:%d" , hour , min , sec );

	mBuffer = buffer;

	return mBuffer.c_str();
}


fint32			GameString::GetTime( const fwchar* buffer )
{
//	mBuffer = buffer;
//	fint32 find ;
//	find=mBuffer.find( GetString("SpareTime") );
//	if (find != -1)
//	{
//		mBuffer.erase( mBuffer.begin() , mBuffer.begin() + wstring(GetString("SpareTime")).size() );
//	}
//
//	find = mBuffer.find( L":" );
//	if (find == -1)
//		return -1;
//
//	find = mBuffer.find( L":" );
//	mBuffer[find] = L'\0';
//	fint32 hour = _wtoi( mBuffer.c_str() );
//	mBuffer.erase( mBuffer.begin() , mBuffer.begin() + find + 1 );
//
//	find = mBuffer.find( L":" );
//	mBuffer[find] = L'\0';
//	fint32 min = _wtoi( mBuffer.c_str() );
//	mBuffer.erase( mBuffer.begin() , mBuffer.begin() + find + 1 );
//
//	fint32 sec = _wtoi( mBuffer.c_str() );
//
//	return hour * 3600 + min * 60 + sec;
    
    return 0;
}


fvoid			GameString::Load( const fbyte* path )
{

}

const fbyte*	GameString::IntToString( int n , int radix /* = 10 */ )
{
	static fbyte buffer[32] = {};

	//_itoa_s( n , buffer , 10 );

	return buffer;
}
